from . import (
    CSVSpliter,
    DOCXSpliter,
    EXCELSpliter,
    PDFSpliter,
    TXTSpliter,
    IFileSpliter,
    ImageSpliter,
)
from ...exception import FileNotSupportedException


class DocumentSpliterFactory:
    _spliter = {
        "pdf": PDFSpliter,
        "txt": TXTSpliter,
        "docx": DOCXSpliter,
        "csv": CSVSpliter,
        "xlsx": EXCELSpliter,
        "png": ImageSpliter,
        "jpg": ImageSpliter,
        "jpeg": ImageSpliter,
    }

    @classmethod
    def get_spliter(cls, file_type: str) -> IFileSpliter:
        loader_cls = cls._spliter.get(file_type.lower())
        if not loader_cls:
            raise FileNotSupportedException(file_type)
        return loader_cls()
